From: kaf24@firebug.cl.cam.ac.uk Date: Fri, 30 Jun 2006 21:19:08 +0000 (+0100) Subject: Provide more specific and helpful error messages during ELF loading. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15912^2~3 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=6b4c5ff3c8f460130e70afdfda1e5424cf22f8e4;p=xen.git Provide more specific and helpful error messages during ELF loading. Signed-off-by: Jimi Xenidis Signed-off-by: Hollis Blanchard --- diff --git a/tools/libxc/xc_load_elf.c b/tools/libxc/xc_load_elf.c index fac1df0a6a..c005409924 100644 --- a/tools/libxc/xc_load_elf.c +++ b/tools/libxc/xc_load_elf.c @@ -170,7 +170,11 @@ static int parseelfimage(const char *image, elf_pa_off = elf_pa_off_defined ? strtoull(p+17, &p, 0) : virt_base; if ( elf_pa_off_defined && !virt_base_defined ) - goto bad_image; + { + ERROR("Neither ELF_PADDR_OFFSET nor VIRT_BASE found in __xen_guest" + " section."); + return -EINVAL; + } for ( h = 0; h < ehdr->e_phnum; h++ ) { @@ -179,7 +183,11 @@ static int parseelfimage(const char *image, continue; vaddr = phdr->p_paddr - elf_pa_off + virt_base; if ( (vaddr + phdr->p_memsz) < vaddr ) - goto bad_image; + { + ERROR("ELF program header %d is too large.", h); + return -EINVAL; + } + if ( vaddr < kernstart ) kernstart = vaddr; if ( (vaddr + phdr->p_memsz) > kernend ) @@ -202,7 +210,10 @@ static int parseelfimage(const char *image, (dsi->v_kernentry < kernstart) || (dsi->v_kernentry > kernend) || (dsi->v_start > kernstart) ) - goto bad_image; + { + ERROR("ELF start or entries are out of bounds."); + return -EINVAL; + } if ( (p = strstr(guestinfo, "BSD_SYMTAB")) != NULL ) dsi->load_symtab = 1; @@ -214,10 +225,6 @@ static int parseelfimage(const char *image, loadelfsymtab(image, 0, 0, NULL, dsi); return 0; - - bad_image: - ERROR("Malformed ELF image."); - return -EINVAL; } static int